package humpty.googlemap.gmapsfirstexample;

/* Imports only for display maps */
import android.os.Bundle;
import android.view.Menu;
import com.google.android.maps.MapActivity;

/* Imports for Controls */
//import android.app.Activity;
import com.google.android.maps.GeoPoint;
import android.view.View;
import com.google.android.maps.MapView;

public class GMapsFirstExampleActivity extends MapActivity {

	/* Variable used to hold location */
	private int currentLat;
	private int currentLong;
	private int step;
	private int zoom;
	
	private GeoPoint gp;
	private MapView gmap;
	
	/** Called when the map opened first time & activity is created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        /* cordinates from http://www.thegpscoordinates.com
         * use Decimal (WGS84)  
         */
        currentLat= 18520510;
        currentLong= 73856733;
        step= 1000;//1000000;
        zoom =12;
        
        gmap=(MapView) findViewById(R.id.map);
        gmap.getController().setCenter(new GeoPoint(currentLat,currentLong));
        gmap.getController().setZoom(zoom);
        zoom = gmap.getZoomLevel();
        gmap.setBuiltInZoomControls(true);
        gmap.setClickable(true);
        gmap.setSatellite(true);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    
    @Override
    protected boolean isRouteDisplayed() { 
    	return false; 
    }
    
   /* Actual Controls */
	public void increaseLat(View v) {		
		currentLat+=step;
		gp=new GeoPoint(currentLat,currentLong);
		gmap.getController().animateTo(gp);
	}
	
	public void decreaseLat(View v) {
		currentLat-=step;
		gp=new GeoPoint(currentLat,currentLong);
		gmap.getController().animateTo(gp);
	}
	
	public void increaseLon(View v) {
		currentLong+=step;
		gp=new GeoPoint(currentLat,currentLong);
		gmap.getController().animateTo(gp);
	}
	
	public void decreaseLon(View v) {
		currentLong-=step;
		gp=new GeoPoint(currentLat,currentLong);
		gmap.getController().animateTo(gp);
	}
	
	public void ZoomIn(View v) {
		zoom+=1;
		gmap.getController().setZoom(zoom);
		zoom= gmap.getZoomLevel();
		gp=new GeoPoint(currentLat,currentLong);
		gmap.getController().animateTo(gp);
	}
	
	public void ZoomOut(View v) {
		zoom-=1;
		gmap.getController().setZoom(zoom);
		zoom= gmap.getZoomLevel();
		gp=new GeoPoint(currentLat,currentLong);
		gmap.getController().animateTo(gp);
	}
}

	
